1498A GCD Sum codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
main()
{
long long int t,n,x,i,r,g;
cin>>t;
while(t--)
{
cin>>n;
while(1)
{
r=0;
x=n;
while(x!=0)
{
r+=x%10;
x/=10;
}
g=__gcd(n,r);
if(g>1)
{
cout<<n<<endl;
break;
}
else n++;
}
}
return 0;
}
0 Comments